﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Web;
using StudentWeb.DAL;
using StudentWeb.Model;
using StudentWeb.Common;

namespace StudentWeb.BLL
{
    public class PicturesBO
    {
        #region 图片信息 全部记录
        public IResult GetPicturesList()
        {
            var list = new PicturesDataDAO().GetList();
            return new DataResult(list);
        }
        #endregion
        #region 图片信息 单条记录
        public IResult GetPicturesInfo(int PictureID)
        {
            var record = new PicturesDataDAO().GetInfo(PictureID);
            return new DataResult(record);
        }
        #endregion
        #region 图片信息 添加
        public bool InsertPicturesInfo(dynamic data)
        {
            var user = new PicturesData()
            {
                TouristID = data.TouristID,
                PictureURL = data.PictureURL,
                PictureDescription = data.PictureDescription,
                UploadDate = data.UploadDate
            };
            var result = new PicturesDataDAO().Insert(user);
            return result > 0;
        }
        #endregion
        #region 图片信息 修改
        public bool UpdatePicturesInfo(dynamic data)
        {
            int PictureID = data.PictureID;
            var record = new PicturesDataDAO().GetInfo(PictureID);
            record.TouristID = data.TouristID;
            record.PictureURL = data.PictureURL;
            record.PictureDescription = data.PictureDescription;
            record.UploadDate = data.UploadDate;
            var result = new PicturesDataDAO().Update(record);
            return result > 0;
        }
        #endregion
        #region 图片信息 删除
        public IResult DeletePicturesInfo(int PictureID)
        {
            var res = new PicturesDataDAO().Delete(PictureID);
            if (res > 0)
            {
                return new Result(ResultCode.Success, "删除成功");
            }
            else
            {
                return new Result(ResultCode.Fail, "删除失败");
            }
        }
        #endregion
    }
}
